package lsy.redis001.lsyredis001.table;

/**
 * @Description redis对应的表字段
 * @Author 刘澍雨
 * @Date 下午 3:41 2020/3/20 0020
 * @Param
 * @return
 **/
public class RedisTableConstant {
    // 文章表（hash） --> article：1
    private static final String ARTICLE = "article:";
    // 文章id队列（list），用于分页查询
    private static final String POSTS_LIST = "posts:list";

    // 文章对应的标签（set） post:1:tags -> "mysql、java标签"
    private static final String POST_ARTICLEID_TAGS_BEFORE = "post:";
    private static final String POST_ARTICLEID_TAGS_AFTER = ":tags";

    // 标签对应的文章（set） tag:MYSQL:posts -> 文章id
    private static final String TAG_TAG_POSTS_BEFORE = "tag:";
    private static final String TAG_TAG_POSTS_AFTER = ":posts";


    public static String getArticleId(Long articleId){
        return ARTICLE + articleId;
    }

    public static String getPostList(){
        return POSTS_LIST;
    }

    public static String getPostArticleTag(Long articleId){
        return POST_ARTICLEID_TAGS_BEFORE + articleId + POST_ARTICLEID_TAGS_AFTER;
    }

    public static String getTagPosts(String tagContent){
        return TAG_TAG_POSTS_BEFORE + tagContent + TAG_TAG_POSTS_AFTER;
    }
}
